package com.gin.kotlin.no_gay_alliance.activity.emoji

import android.content.Context
import android.content.Intent
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import com.gin.kotlin.no_gay_alliance.R
import com.gin.kotlin.no_gay_alliance.adapter.emoji.GenericEmojiPackageAdapter
import com.gin.kotlin.no_gay_alliance.app.App
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingActivity
import com.gin.kotlin.no_gay_alliance.base.AlertDialogUtils
import com.gin.kotlin.no_gay_alliance.databinding.ActivityEmojiConfigBinding

class EmojiConfigActivity:AbstractBindingActivity<ActivityEmojiConfigBinding>() {
    override fun onCreate() {
        val b = this.b ?:return
        val emojiPackages = App.INSTANCE.obtainGenericEmojiPackages()
        b.recyclerView.adapter = GenericEmojiPackageAdapter(this,handler!!,emojiPackages)
    }

    override fun handleIntent(intent: Intent) {
    }

    override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) {
        super.onCreateOptionsMenu(menu, menuInflater)
        menuInflater.inflate(R.menu.info,menu)
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        if (item.itemId==R.id.mi_info){
            AlertDialogUtils.builder(this,getString(R.string.emoji),getString(R.string.emoji_info)).show()
        }
        return super.onOptionsItemSelected(item)
    }

    override fun onResume() {
        super.onResume()
        setToolbarTitle(getString(R.string.emoji))
    }
    companion object{
        @JvmStatic
        fun start(context: Context) {
            val starter = Intent(context, EmojiConfigActivity::class.java)
            context.startActivity(starter)
        }
    }
}